from .models import (
    AllinpayWorkitenTypes,
    AllinpayAuthGroup,
    AllinpayUserList,
    AllinpayStaffList,
    AllinpayPlaceList,
    AllinpayMemberList,
    AllinpayIntegralList,
    AllinpayTermList,
    BMemberList,
)


def initialization():
    # 初始化管理员角色
    AllinpayAuthGroup.objects.update_or_create(
        defaults={"pid": 0, "name": "默认角色"}, id=1
    )
    AllinpayAuthGroup.objects.update_or_create(defaults={"pid": 0, "name": "管理员"}, id=2)

    # 初始化管理员
    AllinpayUserList.objects.update_or_create(
        defaults={
            "name": "超级管理员",
            "phone": "13896370136",
            "status": 1,
            "group": 1,
            "is_active": 1,
            "is_authenticated": 1,
            "is_super": 1,
        },
        id=1,
    )
    # 后台营收
    AllinpayTermList.objects.update_or_create(defaults={"status": 1}, id=1)

    # 初始化场所员工
    AllinpayStaffList.objects.update_or_create(
        defaults={"status": 0, "basename": "测试员工"}, id=1000
    )

    # 初始化场所
    AllinpayPlaceList.objects.update_or_create(
        defaults={"status": 0, "name": "测试场所", "telephone": "13000000000"},
        id=1000000,
    )

    # 初始化会员
    AllinpayMemberList.objects.update_or_create(
        defaults={"pid": 1000000, "name": "测试会员"}, id=1000000000
    )
    BMemberList.objects.update_or_create(
        defaults={"name": "测试会员", "hash": "xxx"}, id=1000000000
    )

    # 初始化工作项类型
    AllinpayWorkitenTypes.objects.update_or_create(defaults={"name": "员工作业"}, id=1)
    AllinpayWorkitenTypes.objects.update_or_create(defaults={"name": "检查作业"}, id=2)
    AllinpayWorkitenTypes.objects.update_or_create(defaults={"name": "保洁作业"}, id=3)
    AllinpayWorkitenTypes.objects.update_or_create(defaults={"name": "定时作业"}, id=4)
    AllinpayWorkitenTypes.objects.update_or_create(defaults={"name": "自动作业"}, id=5)

    # 初始化积分类型
    AllinpayIntegralList.objects.update_or_create(
        defaults={"name": "现金兑换", "status": 1}, id=1
    )
    AllinpayIntegralList.objects.update_or_create(
        defaults={"name": "呼叫积分", "status": 1}, id=2
    )

    print("# [\033[1;32m 初始化 \033[0m] iClouds.wsgi.initialize 全局配置...")
